<?php
//require_once ('../config/path_config.php');
require_once (ROOTDIR."config/db_config.php");
require_once (ROOTDIR."config/sys_config.php");

$HOMEPAGE_NAME=SysConfig::$HP_NAME;
$HOMEPAGE_URL=SysConfig::$HP_URL;
$OJ_NAME=SysConfig::$OJ_NAME;
$OJ_HOME=SysConfig::$OJ_HOME;
$OJ_ADMIN=SysConfig::$OJ_ADMIN;
$OJ_DATA=SysConfig::$OJ_DATA;

static  $OJ_ONLINE=false;
static  $OJ_LANG="cn";
static  $OJ_SIM=false;
static  $OJ_DICT=false;
static  $OJ_LANGMASK=262064; //1mC 2mCPP 4mPascal 8mJava 16mRuby 32mBash 1008 for security reason to mask all other language
static  $OJ_EDITE_AREA=true;//true: syntax highlighting is active
//true: One can view all AC submit if he/she has ACed it onece.
static  $OJ_AUTO_SHARE=true;
static  $OJ_CSS="white.css";
static  $OJ_SAE=false; //using sina application engine
static  $OJ_VCODE=false;
static  $OJ_APPENDCODE=false;
static  $OJ_MEMCACHE=false;
static  $OJ_MEMSERVER="127.0.0.1";
static  $OJ_MEMPORT=11211;
static  $OJ_REDIS=false;
static  $OJ_REDISSERVER="127.0.0.1";
static  $OJ_REDISPORT=6379;
static  $OJ_REDISQNAME="zzoj";
static  $OJ_TEMPLATE="bs3"; //使用的默认模板
if(isset($_GET['tp'])) $OJ_TEMPLATE=$_GET['tp'];
static  $OJ_LOGIN_MOD="hustoj";
static  $OJ_REGISTER=false; //允许注册新用户
static  $OJ_REG_NEED_CONFIRM=false; //新注册用户需要审核
static  $OJ_RANK_LOCK_PERCENT=0; //比赛封榜时间比例
static  $OJ_SHOW_DIFF=true; //是否显示WA的对比说明
static  $OJ_TEST_RUN=false; //提交界面是否允许测试运行
static  $OJ_BLOCKLY=false; //是否启用Blockly界面
static  $OJ_ENCODE_SUBMIT=false; //是否启用base64编码提交的功能，用来回避WAF防火墙误拦截。
static $OJ_OPENID_PWD = '8a367fe87b1e406ea8e94d7d508dcf01';

if( isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && strstr($_SERVER['HTTP_ACCEPT_LANGUAGE'],"zh-CN")) {
        $OJ_LANG="cn";
}
if (isset($_SESSION['OJ_LANG'])) {
    $OJ_LANG=$_SESSION['OJ_LANG'];
}


function pdo_query($sql){
    $num_args = func_num_args();
    $args = func_get_args();
    $args=array_slice($args,1,--$num_args);
    
    global $dbh;
    if(!$dbh){
        $dbh=new PDO("mysql:host=".DbConfig::$DB_HOST.';port='.DbConfig::$DB_PORT.';dbname='.DbConfig::$DB_NAME,
            DbConfig::$DB_USER, DbConfig::$DB_PASS,
                array(PDO::MYSQL_ATTR_INIT_COMMAND => "set names utf8"));
    }
    $sth = $dbh->prepare($sql);
    $sth->execute($args);
    $result=array();
    if(stripos($sql,"select") === 0){
        $result=$sth->fetchAll();
    }else if(stripos($sql,"insert") === 0){
	    $result=$dbh->lastInsertId();
    }else{
        $result=$sth->rowCount();
    }
    $sth->closeCursor();
    return $result;
}

function pdo_query2($sql, $args){

    global $dbh;
    if(!$dbh){
        $dbh=new PDO("mysql:host=".DbConfig::$DB_HOST.';port='.DbConfig::$DB_PORT.';dbname='.DbConfig::$DB_NAME,
            DbConfig::$DB_USER, DbConfig::$DB_PASS,
            array(PDO::MYSQL_ATTR_INIT_COMMAND => "set names utf8"));
    }
    $sth = $dbh->prepare($sql);
    $sth->execute($args);
    $result=array();
    if(stripos($sql,"select") === 0){
        $result=$sth->fetchAll();
    }else if(stripos($sql,"insert") === 0){
        $result=$dbh->lastInsertId();
    }else{
        $result=$sth->rowCount();
    }
    $sth->closeCursor();
    return $result;
}

if(isset($OJ_CSRF)&&$OJ_CSRF&&$OJ_TEMPLATE=="bs3") {
    require_once('csrf_check.php');
}
date_default_timezone_set("PRC");
//pdo_query("SET time_zone ='+8:00'");

?>
